#include <vector>
#include <iostream>
using namespace std;

class Solution
{
public:
    int numberOfArithmeticSlices(vector<int> &nums)
    {
        if (nums.size() < 3)
            return 0;
        if (nums.size() == 3)
            return 1;
        int res = 0;
        for (int i = 0; i <= nums.size() - 3; i++)
        {
            for (int j = i + 2; j < nums.size(); j++)
            {
                if (nums[j] - nums[j - 1] == nums[j - 1] - nums[j - 2])
                    res++;
                else
                    break;
            }
        }
        return res;
    }
};